package tld.test.menu
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import tld.test.interpreter.runtime.Runtime;
	import tld.test.menu.challenges.ChallengeTheChallenge;
	
	[SWF(width=600, height=600)]
	
	/**
	 * This is the main application class, for building it see README
	 */
	public class MenuDemo extends Sprite
	{
		private const _challenge:ChallengeTheChallenge = 
			new ChallengeTheChallenge();
		
		private const _runtime:Runtime = new Runtime();
		
		private const _console:Console = new Console(_runtime);
		
		public function MenuDemo()
		{
			super();
			if (super.stage) this.init();
			else super.addEventListener(
				Event.ADDED_TO_STAGE, this.init);
		}
		
		private function init(event:Event = null):void
		{
			super.removeEventListener(
				Event.ADDED_TO_STAGE, this.init);
			super.stage.scaleMode = StageScaleMode.NO_SCALE;
			super.stage.align = StageAlign.TOP_LEFT;
			this._console.width = super.stage.stageWidth;
			this._console.height = 300;
			super.addChild(this._console);
			this._challenge.y = 300;
			super.addChild(this._challenge);
			this._challenge.setConsole(this._console);
			this._challenge.setRuntime(this._runtime);
		}
	}
}